package exam.test10;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Endstart
 * Date: 2020-11-04
 * Time: 10:51
 */
public class R {
    int num = 1;

    public int doS(int a) {
        this.num += 1;
        return this.num * a;
    }

    public static void main(String[] args) {
        List<R> list = new ArrayList<>();
        list.add(new S());
        list.add(new T());
        for (R r : list) {
            System.out.println(r.doS(1));

        }
    }
}

class S extends R {

    @Override
    public int doS(int a) {
        this.num += 1;
        return this.num * super.doS(a);
    }
}

class T extends S {

    @Override
    public int doS(int a) {
        this.num += 1;
        return this.num * super.doS(a);
    }
}
